package com.lblin.service;

import java.io.File;
import java.io.IOException;
import java.net.URL;

import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;

import com.lblin.tio.server.HelloServerStarter;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;

//@SpringBootApplication
public class Server {

	public static void main( String[] args ) throws IOException
    {
//		new SpringApplicationBuilder()
//        .sources(Server.class)
//        .web(false)
//        .run(args);
        
        //启动tio server
		
		
		URL url = new Server().getClass().getClassLoader().getResource("logback-spring.xml");
		
		File logbackFile = new File(url.getFile());
		
		if(logbackFile.exists()){
			LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
            JoranConfigurator configurator = new JoranConfigurator();
            configurator.setContext(lc);
            lc.reset();
            try {
                configurator.doConfigure(logbackFile);
            }
            catch (JoranException e) {
                e.printStackTrace(System.err);
                System.exit(-1);
            }
		}
		
		args = new String[] {"6781","server-1"};
		
        HelloServerStarter.main(args);
    }
}
